<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="app">
        <table>
            <tr>
                <th>名字</th>
                <th>价格</th>
                <th>数量</th>
            </tr>
            <tr v-for="all in arr" :key="arr.id">
                <td>{{all.name}}</td>
                <td>{{all.price}}</td>
                <td>{{all.num}}</td>
            </tr>
        </table>
        总价：{{allprice}}
    </div>
    <script src="../js/vue.js"></script>
    <script>
        const app = new Vue({
            el: "#app",
            data: {
                arr: [
                    { "id": 1, "price": 1000, "num": 1, "name": "电视机" },
                    { "id": 2, "price": 2000, "num": 2, "name": "电冰箱" },
                    { "id": 3, "price": 3000, "num": 3, "name": "电磁路" },

                ]
            },
            computed:{
                allprice(){
                    let total = 0;
                    for(let i =0;i<this.arr.length;i++){
                        total+=this.arr[i].price*this.arr[i].num
                    }
                    return total;
                }
            }
        })
    </script>
</body>

</html>